package com.jc.ds.model;

import java.util.List;

/**
 * permission
 * @author 
 */
public class Permission extends BaseValueObject {
    private Long id;

    /**
     * 用户TOKEN
     */
    private String code;

    /**
     * 资源URL
     */
    private String url;

    /**
     * 图标
     */
    private String icon;

    /**
     * 资源说明
     */
    private String description;

    /**
     * 0 按钮资源 1 菜单资源
     */
    private Integer permissionType;

    /**
     * 父权限ID
     */
    private Long parentId;
    /**
     * 按钮
     * */
    private List<Permission> buttonList;
    /**
     * 子菜单
     * */
    private List<Permission> children;
    /**
     * 是否拥有权限
     * */
    private Boolean isChecked;

    public List<Permission> getButtonList() {
        return buttonList;
    }

    public void setButtonList(List<Permission> buttonList) {
        this.buttonList = buttonList;
    }

    public Boolean getChecked() {
        return isChecked;
    }

    public void setChecked(Boolean checked) {
        isChecked = checked;
    }

    public List<Permission> getChildren() {
        return children;
    }

    public void setChildren(List<Permission> children) {
        this.children = children;
    }

    private String orderStr = null;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }

    public String getIcon() {
        return icon;
    }

    public void setIcon(String icon) {
        this.icon = icon;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public Integer getPermissionType() {
        return permissionType;
    }

    public void setPermissionType(Integer permissionType) {
        this.permissionType = permissionType;
    }

    public Long getParentId() {
        return parentId;
    }

    public void setParentId(Long parentId) {
        this.parentId = parentId;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }
    public void orderById(boolean isAsc) {
        if(isAsc){
            if(this.orderStr == null){
                this.orderStr = "order by id asc";
            }else{
                this.orderStr = this.orderStr + ",id asc";
            }
        }else{
            if(this.orderStr == null){
                this.orderStr = "order by id desc";
            }else{
                this.orderStr = this.orderStr + ",id desc";
            }
        }
    }

    public void orderByToken(boolean isAsc) {
        if(isAsc){
            if(this.orderStr == null){
                this.orderStr = "order by token asc";
            }else{
                this.orderStr = this.orderStr + ",token asc";
            }
        }else{
            if(this.orderStr == null){
                this.orderStr = "order by token desc";
            }else{
                this.orderStr = this.orderStr + ",token desc";
            }
        }
    }

    public void orderByUrl(boolean isAsc) {
        if(isAsc){
            if(this.orderStr == null){
                this.orderStr = "order by url asc";
            }else{
                this.orderStr = this.orderStr + ",url asc";
            }
        }else{
            if(this.orderStr == null){
                this.orderStr = "order by url desc";
            }else{
                this.orderStr = this.orderStr + ",url desc";
            }
        }
    }

    public void orderByIcon(boolean isAsc) {
        if(isAsc){
            if(this.orderStr == null){
                this.orderStr = "order by icon asc";
            }else{
                this.orderStr = this.orderStr + ",icon asc";
            }
        }else{
            if(this.orderStr == null){
                this.orderStr = "order by icon desc";
            }else{
                this.orderStr = this.orderStr + ",icon desc";
            }
        }
    }

    public void orderByDescription(boolean isAsc) {
        if(isAsc){
            if(this.orderStr == null){
                this.orderStr = "order by description asc";
            }else{
                this.orderStr = this.orderStr + ",description asc";
            }
        }else{
            if(this.orderStr == null){
                this.orderStr = "order by description desc";
            }else{
                this.orderStr = this.orderStr + ",description desc";
            }
        }
    }

    public void orderByPermissionType(boolean isAsc) {
        if(isAsc){
            if(this.orderStr == null){
                this.orderStr = "order by permission_type asc";
            }else{
                this.orderStr = this.orderStr + ",permission_type asc";
            }
        }else{
            if(this.orderStr == null){
                this.orderStr = "order by permission_type desc";
            }else{
                this.orderStr = this.orderStr + ",permission_type desc";
            }
        }
    }

    public void orderByParentId(boolean isAsc) {
        if(isAsc){
            if(this.orderStr == null){
                this.orderStr = "order by parent_id asc";
            }else{
                this.orderStr = this.orderStr + ",parent_id asc";
            }
        }else{
            if(this.orderStr == null){
                this.orderStr = "order by parent_id desc";
            }else{
                this.orderStr = this.orderStr + ",parent_id desc";
            }
        }
    }
}